package com.tangula.web.kashine.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.tangula.web.kashine.entity.CostListForm;
@Repository
public interface CostListRepository extends JpaRepository<CostListForm, String>{
	@Query(nativeQuery=true,value="SELECT c.id AS id,c.id AS class_id,c.class_name AS class_name,SUM( h.money ) AS total_cost,cs.student_name_in_class AS top_earner_name,h.money AS top_earner_money_amount FROM t_history h,t_class c,t_product p,t_classstudentref cs WHERE h.resave_id = :teacherId AND h.class_id = c.id AND c.class_product = p.id AND c.id = cs.class_id GROUP BY h.class_id")
	List<CostListForm> loadTeacherHomeCostList(@Param("teacherId")String teacherid);

}
